//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

public class demo_2255 {
    public demo_2255() {
    }

    public static void main(String[] args) {
        String[] words = new String[]{"a", "b", "c", "ab", "bc", "abc"};
        System.out.println(countPrefixes(words, "abc"));
    }

    public static int countPrefixes(String[] words, String s) {
        int count = 0;

        for(int i = 0; i < s.length(); ++i) {
            String word = s.substring(0, i + 1);

            for(String str : words) {
                if (word.equals(str)) {
                    ++count;
                }
            }
        }

        return count;
    }

    public static int countPrefixes2(String[] words, String s) {
        int count = 0;

        for(String str : words) {
            if (s.startsWith(str)) {
                ++count;
            }
        }

        return count;
    }
}
